/*
 * Copyright 2010 - 2011, The PLDesktop Development Team
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 */

#ifndef PLJAVA_METHOD_INFO_H
#define PLJAVA_METHOD_INFO_H

#include <filetypes/PLJavaAttribute.h>
#include <filetypes/PLJavaFieldDescriptor.h>
#include <filetypes/PLJavaAttributeInterface.h>

namespace PLSDK {

class PLJavaAttributeCode;

/**
 * Class that hold the methode information.
 */
class PLJavaMethodeInfo : public PLJavaAttributeInterface {
public:
    /**
     * Constructor.
     *
     * @param newAccessFlags The access flags from the field info.
     * @param newNameIndex The name.
     * @param newDescriptorIndex The index of the descriptor.
     */
    PLJavaMethodeInfo(PLJavaFile::AccessFlags newAccess, PLJavaConstTypesUtf8 *newName, PLJavaFieldDescriptor *newDescriptor);
    /**
     * Destructor.
     */
    ~PLJavaMethodeInfo();
    /**
     * Get the access flags from the field information.
     *
     * @return The access flags.
     */
    inline PLJavaFile::AccessFlags accessFlags();
    /**
     * Get the name.
     *
     * @return The index.
     */
    inline PLJavaConstTypesUtf8 *name();
    /**
     * Get the descriptor index.
     *
     * @return The index.
     */
    inline PLJavaFieldDescriptor *descriptor();
    /**
     * Add new attribute information to the attributes.
     *
     * @param newAttribute The attribute to add.
     */
    void addAttribute(PLJavaAttribute *newAttribute);
    /**
     * Get the attribute at a index.
     *
     * @return The attribute.
     */
    PLJavaAttribute *attributeAt(u2 index);
    /**
     * Get the number of attributes.
     *
     * @return The number.
     */
    inline u2 attributesCount();
    /**
     * Get the code information.
     *
     * @return The code.
     */
    PLJavaAttributeCode *code();
private:
    PLJavaFile::AccessFlags m_accessFlags;
    PLJavaConstTypesUtf8 *m_name;
    PLJavaFieldDescriptor *m_descriptor;
    PLVector<PLJavaAttribute *> m_attributes;
    PLJavaAttributeCode *m_code;
};

PLJavaFile::AccessFlags PLJavaMethodeInfo::accessFlags() {
    return m_accessFlags;
}

PLJavaConstTypesUtf8 *PLJavaMethodeInfo::name() {
    return m_name;
}

PLJavaFieldDescriptor *PLJavaMethodeInfo::descriptor() {
    return m_descriptor;
}

u2 PLJavaMethodeInfo::attributesCount() {
    return m_attributes.count();
}

}

#endif
